package top.lixunda.ecommerce.server.user.api.entity.db;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * VIEW
 * </p>
 *
 * @author Xumda
 * @since 2019-11-22
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("user_detail")
public class UserDetailDO extends Model<UserDetailDO> {

    private static final long serialVersionUID=1L;

    /**
     * 官方用户唯一账户
     */
    @TableField("account")
    private Integer account;

    /**
     * 加密后的登录密码，若未设置密码则为空字符窜
     */
    @TableField("password")
    private String password;

    /**
     * 注册时间
     */
    @TableField("create_time")
    private LocalDateTime createTime;

    /**
     * 最后一次更新时间
     */
    @TableField("update_time")
    private LocalDateTime updateTime;

    /**
     * token
     */
    @TableField("token")
    private String token;

    /**
     * token更新时间
     */
    @TableField("token_time")
    private LocalDateTime tokenTime;

    /**
     * 密码提示问题
     */
    @TableField("pass_hint")
    private String passHint;

    /**
     * 密码提示问题答案
     */
    @TableField("pass_hint_ans")
    private String passHintAns;

    /**
     * 用户类型，如管理员
     */
    @TableField("user_type")
    private String userType;

    /**
     * 当前账户是否可用
     */
    @TableField("forbidden")
    private Integer forbidden;

    @TableField("forbidden_name")
    private String forbiddenName;

    /**
     * 当账户不可用时描述原因
     */
    @TableField("forbidden_desc")
    private String forbiddenDesc;

    /**
     * 用户描述信息，标记
     */
    @TableField("remark")
    private String remark;

    /**
     * 绑定的账号
     */
    @TableField("bind_account")
    private String bindAccount;

    /**
     * 绑定账号类型
     */
    @TableField("binding_type_id")
    private Integer bindingTypeId;

    /**
     * 登陆方式名称
     */
    @TableField("binding_type_name")
    private String bindingTypeName;

    /**
     * 是否是三方账户，手机号，邮箱不属于三方账户
     */
    @TableField("third_account")
    private Integer thirdAccount;

    @TableField("third_account_name")
    private String thirdAccountName;

    @Override
    protected Serializable pkVal() {
        return null;
    }

    public UserDetailDO copy() {
        UserDetailDO detail = new UserDetailDO();
        BeanUtils.copyProperties(this, detail);
        return detail;
    }

}
